package thread;

class PrintNum extends Thread{
    public PrintNum(String name) {
        super(name);
    }

    public void run(){
        //子线程执行的代码
        for(int i = 1;i <= 100;i++){
            if(i % 2 == 0){
                System.out.println(Thread.currentThread().getName() + ":" + i);
            }
        }
    }
}


public class TestThread {
    public static void main(String[] args) {
        PrintNum p1 = new PrintNum("线程1");
        PrintNum p2 = new PrintNum("线程2");
        p1.start();
        p2.start();
    }
}
